package cn.test.shard.rule;

import java.util.Collection;
import java.util.LinkedHashSet;

import com.dangdang.ddframe.rdb.sharding.api.ShardingValue;
import com.dangdang.ddframe.rdb.sharding.api.strategy.database.SingleKeyDatabaseShardingAlgorithm;

/**
 * @author Han
 */
public class DatabaseShardingAlgorithm implements SingleKeyDatabaseShardingAlgorithm<Integer>{

	@Override
	public String doEqualSharding(Collection<String> availableTargetNames, ShardingValue<Integer> shardingValue) {
		int code = shardingValue.getValue() % 1024;
		if(code < 512){
			return "db0";
		}else{
			 return "db1";
		}
	}

	@Override
	public Collection<String> doInSharding(Collection<String> availableTargetNames, ShardingValue<Integer> shardingValue) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Collection<String> doBetweenSharding(Collection<String> availableTargetNames, ShardingValue<Integer> shardingValue) {
		// TODO Auto-generated method stub
		return null;
	}

}
